package com.kgc.cn.controller;

import com.kgc.cn.clients.ZipkinClients;
import com.kgc.cn.dto.ZipkinSpans;
import com.kgc.cn.utils.RedisUtils;
import com.kgc.cn.utils.ReturnResult;
import com.kgc.cn.utils.ReturnResultUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author jialin
 * @create 2020-10-24
 */
@Api(tags = "SpringCloud测试接口Zipkin")
@RestController
@RequestMapping(value = "/test")
public class ZipkinController {

    @Autowired
    private ZipkinClients zipkinClients;

    @Autowired
    private RedisUtils redisUtils;

    @ApiOperation(value = "测试返回zipkin对象接口")
    @GetMapping(value = "/getName")
    public ReturnResult<ZipkinSpans> getName(@RequestParam(value = "id") Long id) {
        redisUtils.set("testCloud", zipkinClients.getName(id).toString());
        return ReturnResultUtils.returnSuccess(zipkinClients.getName(id));
    }

    @ApiOperation(value = "测试返回zipkin对象接口2")
    @GetMapping(value = "/getNo")
    public ReturnResult<ZipkinSpans> getNo(@RequestParam(value = "id") Long id) {
        redisUtils.set("testCloud", zipkinClients.getName(id).toString());
        return ReturnResultUtils.returnSuccess(zipkinClients.getName(id));
    }

}
